<?php
/**
 * Description:
 *
 * @author      Eden
 * @datetime    2017/2/3 20:33
 * @copyright   WuHan HuQi Technology Co.,Ltd.
 * @url         http://cnhuqi.com
 */

use Wechat\Loader;

class Config extends WX_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取配置
     */
    public function getJSSDKConfig()
    {
        Loader::config($this->options);
        $wechat = Loader::get('script');
        $url = $_SERVER['HTTP_REFERER'];
        if (empty($url)) {
            $url = WX_URL;
        }
        $res = $wechat->getJsSign($url);
        if ($res) {
            $wxjs = "wx.config({
                            debug: false,
                            appId: '".$res['appId']."',
                            timestamp: ".$res['timestamp'].",
                            nonceStr: '".$res['nonceStr']."',
                            signature: '".$res['signature']."',
                            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'chooseWXPay']
                            });";
            echo $wxjs;
        }

        exit;
    }
}
